<?php
/**
 * EGP Framework
 *
 * LICENSE
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @author     Akon(番茄红了) <aultoale@gmail.com>
 * @copyright  Copyright (c) 2008 (http://www.tblog.com.cn)
 * @license    http://www.gnu.org/licenses/gpl.html     GPL 3
 */

/**
 * 项目入口引导文件
 *
 * @package    script
 * @author     Akon(番茄红了) <aultoale@gmail.com>
 * @copyright  Copyright (c) 2008 (http://www.tblog.com.cn)
 * @license    http://www.gnu.org/licenses/gpl.html     GPL 3
 */

/**
 * 设定页面编码
 */
@header("Content-type: text/html; charset=utf-8");

/**
 * 设定时区
 */
date_default_timezone_set('Asia/Shanghai');

/**
 * 设定项目开始时间
 */
define('START_TIME', microtime(true));

/**
 * 简化定义 PHP 路径常量
 */
!defined('DIR_SEP')  && define('DIR_SEP',  DIRECTORY_SEPARATOR);
!defined('PATH_SEP') && define('PATH_SEP', PATH_SEPARATOR);
!defined('__DIR__')  && define('__DIR__',  dirname(__FILE__));

/**
 * 定义项目目录结构
 */
define('LIB_DIR', __DIR__);
define('WEB_DIR', dirname(LIB_DIR) . DIR_SEP . 'www');  // 网站启动目录
define('CONFIG_DIR', LIB_DIR . DIR_SEP . 'config');  // 配置文件目录
define('TMP_DIR', dirname(LIB_DIR) . DIR_SEP . 'templates'); // 模版目录

/**
 * 开启错误捕获
 */
@ini_set('track_errors', true);

/**
 * 报告所有错误
 */
error_reporting(E_ALL);

/**
 * 载入自定通用函数
 */
require(LIB_DIR . DIR_SEP  . 'Function' . DIR_SEP . 'Function.php');

require(LIB_DIR . DIR_SEP . 'Core.php');

/**
 * 设定 include_path
 */
Core::setIncludePath(LIB_DIR);

/**
 * 设定异常处理控制器
 */
set_exception_handler(array('Core', 'exceptionHandler'));

/**
 * 设定错误处理控制器
 */
set_error_handler(array('Core', 'errorHandler'));


/**
 * 注册自动加载类
 */
Core::registerAutoload();

/**
 * 运行环境配置文件
 */
$appConfig = Core::loadConfig('config');

/**
 * 创建数据库连接
 */
$db = EGP_Db::factory($appConfig->db->adapter, $appConfig->db->config);
$data = $db->select()
    ->from('user')
    ->where('uid = 5')
    ->fetchAll();
print_r($data);
//print_r($config);
//$a = new a();
//$a = new I_b();


